from flask import Flask
from .config import Config

def create_app():
    app = Flask(__name__)
    app.config.from_object(Config)
    
    # 延迟导入以避免循环依赖
    from .celery import celery
    from . import tasks
    celery.conf.update(app.config)
    celery.autodiscover_tasks(['app.tasks'], force=True)
    
    # 延迟导入路由
    from .routes import init_routes
    init_routes(app)
    
    return app

app = create_app()
